package cn.yuanqiao.web.controller.archive.wenjianzhengli;/**
 * @author 赵常飞
 * @date 2023/6/20 20:07
 */

import cn.yuanqiao.archive.appManager.domain.YqdaTrees;
import cn.yuanqiao.archive.wenjianzhengli.domain.TenantTablehead;
import cn.yuanqiao.archive.wenjianzhengli.service.IWenjianhuishouzhanService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.web.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;

import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 *
 *@AUTHOR:赵常飞
 *@date 2023/6/20 20:07
 */
@RestController
@RequestMapping("/archive/wjhsz")
public class WenjianhuishouzhanController extends BaseController {

    @Autowired
    private IWenjianhuishouzhanService wenjianhuishouzhanService;

    /**
     * 根据层级获取所有门类 0:件 1:卷 3:项目
     */
    //@PreAuthorize("@ss.hasPermi('manage:wjhsz:list')")
    @Log(title = "回收站获取列表", businessType = BusinessType.SELECT)
    @PostMapping("/getdatalist")
    public TableDataInfo getdatalist(@RequestBody JSONObject json)
    {
        List<Map<String,Object>> list = wenjianhuishouzhanService.getdatalist(json);
        return getDataTable(list);
    }

    /**
     * 恢复
     * @param json
     * @return
     */
    @PreAuthorize("@ss.hasPermi('archive:wjhsz:restore')")
    @Log(title = "回收站恢复文件", businessType = BusinessType.UPDATE)
    @PostMapping("/restore")
    public AjaxResult restore(@RequestBody JSONObject json){
        return success(wenjianhuishouzhanService.restore(json));
    }
    /**
     * 恢复
     * @param json
     * @return
     */
    @PreAuthorize("@ss.hasPermi('archive:dahsz:restore')")
    @Log(title = "回收站恢复档案", businessType = BusinessType.UPDATE)
    @PostMapping("/restoreda")
    public AjaxResult restoreda(@RequestBody JSONObject json){
        return success(wenjianhuishouzhanService.restore(json));
    }

    /**
     * 彻底删除
     * @param json
     * @return
     */
    @Log(title = "回收站彻底删除文件", businessType = BusinessType.DELETE)
    @PostMapping("/delete")
    @PreAuthorize("@ss.hasPermi('archive:wjhsz:delete')")
    public AjaxResult delete(@RequestBody JSONObject json){
        List<List> list=wenjianhuishouzhanService.delete(json);
        wenjianhuishouzhanService.deleteefile(list);
        return success("彻底删除成功!");
    }
    /**
     * 彻底删除
     * @param json
     * @return
     */
    @Log(title = "回收站彻底删除档案", businessType = BusinessType.DELETE)
    @PostMapping("/deleteda")
    @PreAuthorize("@ss.hasPermi('archive:dahsz:delete')")
    public AjaxResult deleteda(@RequestBody JSONObject json){
        List<List> list=wenjianhuishouzhanService.delete(json);
        wenjianhuishouzhanService.deleteefile(list);
        return success("彻底删除成功!");
    }
    /** 根据件id获取门类id */
    @PostMapping("/getcateidbyid")
    public AjaxResult getcateidbyid(@RequestBody JSONObject json){
        return success(wenjianhuishouzhanService.getcateidbyid(json));
    }



    //添加
    @PostMapping("/addhead")
    public AjaxResult addhead(@RequestBody TenantTablehead tablehead){
        return success(wenjianhuishouzhanService.addhead(tablehead));
    }

    //回显
    @PostMapping("/gethead")
    public AjaxResult gethead(@RequestBody TenantTablehead tablehead){
        return success(wenjianhuishouzhanService.gethead(tablehead));
    }
}
